package com.borened.common.core.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * 请求工具类
 *
 * @author <boren1007@qq.com>
 * @since 2022/9/7 18:54
 */
public class RequestUtils {

    /**
     * 从当前请求上下文中获取 HttpServletRequest实例
     *
     * @return
     */
    public static HttpServletRequest getRequest() {
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    }
}
